﻿@using MrCMS.Batching.Entities
@using MrCMS.Web.Areas.Admin.Services.Batching
@model MrCMS.Batching.Entities.BatchRun
@{
    var completionStatus = ViewData["completion-status"] is BatchCompletionStatus ? (BatchCompletionStatus)ViewData["completion-status"] : new BatchCompletionStatus();
}
<tr data-batch-run-id="@Model.Id" data-refresh-url="@Url.Action("Row", "BatchRun", new { Model.Id })">
    <td>
        @Model.CreatedOn
    </td>
    <td data-batch-run-status="@Model.Id">
        @Model.Status
    </td>
    <td>
        <div class="progress" style="margin-bottom: 0">
            <div data-batch-run-progress-bar="@Model.Id" class="progress-bar progress-bar-striped @(Model.Status == BatchRunStatus.Executing ?"active":"")" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: @completionStatus.PercentageCompleted;">
                <span data-batch-run-full-status="@Model.Id">
                    @completionStatus.PercentageCompleted (@completionStatus.Completed of @completionStatus.Total)
                </span>
            </div>
        </div>
    </td>
    <td data-batch-run-time-taken="@Model.Id">
        @completionStatus.TimeTaken
    </td>
    <td>
        <div class="btn-group">
            @Html.ActionLink("Show", "Show", "BatchRun", new { id = Model.Id }, new { @class = "btn btn-default btn-xs" })
            @{Html.RenderPartial("ShowButton", Model, new ViewDataDictionary { { "classes", "btn-xs" } });}
        </div>
    </td>
</tr>